const app = getApp()
const config = require('../../config.js');
Page({
	data: {
		serviceList: [], // 三级
		noData: false,
		value: "",
		autoFocus: true
	},
	onShow() {
		this.getDataList(this.options.id)
	},
	// 数据整理 index 一级下标  val 二级下标
	getDataList(id) {
		let vm = this
		wx.request({
			url: config.searchService,
			data: {
				"key": '',
				"type": id,
			},
			header: {
				tenantId: 1003,
				'content-type': 'application/json', // 默认值
			},
			success(response) {
				console.log(response.data)
				let result = response.data
				if (result.code === '0000') {
					if (result.data) {
						vm.setData({
							serviceList: result.data,
							noData: false
						})
					} else {
						vm.setData({
							serviceList: [],
							noData: true
						})
					}
				} else {
					vm.setData({
						serviceList: [],
						noData: true
					})
				}
			}
		})
	},
	// 详情
	getDetails(e) {
		let id = e.currentTarget.dataset.id
		wx.navigateTo({
			url: '/pages/details/details?id=' + id,
		})
	},
})
